<template>
<view>
	<view class="list" v-for="(item,index) in list" :key="index">
		<view class="item" v-if="role ==2">企业名称:{{item.name}}</view>
		<view class="item" v-if="role ==2">岗位名称:{{item.job}}</view>
		
		<view class="item" v-if="role ==3">姓名:{{item.realname}}</view>
		<view class="item" v-if="role ==3">求职岗位:{{item.post}}</view>
		
		<view class="item">工作地点:{{item.city}}</view>
		
		<view class="item" v-if="role ==2">面试时间:{{item.date}}{{item.time}}</view>
		<view class="item" v-if="role ==2">联系电话:{{item.phone}}</view>
		<view class="item" v-if="role ==2">负责人:{{item.contacts}}</view>
		
		<view class="item" v-if="role ==3">出生日期:{{item.birthDay}}</view>
		<view class="item" v-if="role ==3">性别:{{item.sex}}</view>
		<view class="item" v-if="role ==3">期望薪资:{{item.money}}</view>
		
		<view class="line_footer">
			<view class="left" @click="del(item.id,index)">删除</view>
			<view class="right" @click="toUser(item.uid)">发起聊天</view>
		</view>
	</view>
</view>
</template>
<script>
import request from '@/util/request.js'
export default {
	data() {
		return {
			avatarUrl: '/static/qrcode.jpg',
			nickName:'',
			role:0,
			list:[]
		}
	},
	onLoad:function() {
		this.role = uni.getStorageSync('role')
		uni.showLoading({
		    title: '加载中'  
		});
		this.getList()
	},
	methods: {
		getList:function(){
			var that = this
			var data = {uid:uni.getStorageSync('uid')}
			request({
				url: 'interview/list',
				method: 'get',
				data:data,
				success: (res) => {
					console.log(res)
					uni.hideLoading()
					that.list = res.data.data
				}
			})
		},
		toUser:function(uid){
			if(uni.getStorageSync('role') == 2){
				//直接发起聊天
				uni.navigateTo({
					url:'/pages/message/online/toCompany?touid='+uid
				});
				return;
			}
			var that = this
			var data = {
				company_uid:uni.getStorageSync('uid'),
				uid:uid
			}
			request({
				url: 'vip/is_buy',
				method: 'get',
				data:data,
				success: (res) => {
					if(res.data.code == 1){
						uni.navigateTo({
							url: '/pages/message/online/toCompany?touid='+uid
						})
					}else{
						uni.showToast({
							title:'VIP已过期',
							icon: 'none',
							duration: 2000,
							success() {
								setTimeout(function() {
									uni.navigateTo({
										url:'/pages/vip/index'
									});
								}, 2000);
							}
						})
					}
				}
			})
		},
		del:function(id,index){
			var that = this
			var data ={id:id}
			request({
				url: 'interview/del',
				method: 'delete',
				data:data,
				success: (res) => {
					uni.hideLoading()
					if(res.data.code == 1){
						uni.showToast({
							title: '删除成功!!!',
							icon: "success", 
							position:'bottom',
						});
						that.list.splice(index,1)
					}
				}
			})
		},
		jump:function(url){
			uni.navigateTo({
			  url:url
			})
		}
	}
}
</script>
<style>
.list{
	display: flex;
	flex-direction: column;
	padding: 15rpx 15rpx 20rpx 20rpx;
	border-bottom: 5rpx solid #CCCCCC;
}
.item{
	font-weight: 900;
	font-size:15px;
	height: 80rpx;
	line-height: 80rpx;
}
.line_footer{
	width:100%;
	display: flex;
	flex-direction: row;
	justify-content: space-between;
}
.left{
	width:150rpx;
	height:60rpx;
	line-height: 60rpx;
	border-radius: 30rpx;
	color:#FFFFFF;
	background: #e60000;
	font-size:12px;
	text-align: center;
}
.left1{
	width:150rpx;
	height:60rpx;
	line-height: 60rpx;
	border-radius: 30rpx;
	color:#FFFFFF;
	background: #00b359;
	font-size:12px;
	text-align: center;
}
.right{
	width:150rpx;
	height:60rpx;
	line-height: 60rpx;
	border-radius: 30rpx;
	color:#FFFFFF;
	background: #0000e6;
	font-size:12px;
	text-align: center;
}
</style>